class Class {
    constructor(_number){
        this.number = _number;
    }
    getDisplayName(){
        return `Class ${this.number}` ;
    }
    registerAssignLeaderListener(_teacher){//传入授课老师
        this.teacher = _teacher ;
    }
    registerJoinListener(_teacher){
        this.teacher = _teacher ;
    }
    assignLeader(_student){
        if(this.isIn(_student)){
            this.leader = _student ;
            if(this.teacher){
                console.log(`I am ${this.teacher.name}. I know ${_student.name} become Leader of Class ${this.number}.`) ;
            }
            return true ;//班长设置成功
        }else{
            console.log(`It is not one of us.`);
            return false ;//班长设置失败
        }
    }
    appendMember(_student){
        _student.klass = this ;
        if(this.teacher){
            console.log(`I am ${this.teacher.name}. I know ${_student.name} has joined Class 2.`) ;
        }
        return 0 ;
    }
    isIn(_student){
        return _student.klass === this ;
    }

}
module.exports = Class ;
